﻿using MapleLeaf.Core;
using MapleLeaf.Core.AppSetting;
using MapleLeaf.Core.Extension;
using MapleLeaf.Model.CookBook;
using System.Reflection;

namespace MapleLeaf.WebApi.CookBook.Components {
    /// <summary>
    /// 
    /// </summary>
    public static class InitTableComponent {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="builder"></param>
        public static void AddInitTableComponent(this WebApplicationBuilder builder) {
         


            Assembly assembly = typeof(RecipeEntity).Assembly;
            Type[] allTypes = assembly.GetTypes();


            Task.Run(() => {
                Type[] localtypes = allTypes.Where(it => it.FullName!.StartsWith("MapleLeaf.Model.CookBook")).ToArray();
                SqlSugarHelper.MasterDb.CodeFirst.SetStringDefaultLength(2000).InitTables(localtypes);
            });
        }
    }
}

